import 'package:flutter/material.dart';

class DismissKeyBord extends StatelessWidget {
  final Widget? child;

  const DismissKeyBord({super.key, this.child});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
      child: child,
    );
  }
}

class CommonGestureDetector extends StatelessWidget {
  final Widget? child;
  final GestureTapCallback? onTap;
  final GestureLongPressCallback? onLongPress;
  final EdgeInsetsGeometry? padding;

  const CommonGestureDetector(
      {super.key, this.child, this.onTap, this.onLongPress, this.padding});

  @override
  Widget build(BuildContext context) {
    Widget widget = GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      onLongPress: onLongPress,
      child: child,
    );
    if (padding != null) {
      widget = Padding(
        padding: padding ?? EdgeInsets.zero,
        child: widget,
      );
    }
    return widget;
  }
}
